import { NextFunction, Request, Response } from 'express'
import { AppError } from './errorHandler'

export const adminMiddleware = (req: Request, res: Response, next: NextFunction) => {
  try {
    if (req.user?.role !== 'admin') {
      throw new AppError('Admin access required', 403)
    }
    next()
  } catch (error) {
    next(error)
  }
}
